package com.leetcode.Offer;

import java.util.Arrays;

public class JZ61 {
    public boolean isStraight(int[] nums) {

        Arrays.sort(nums);
        int num0 = 0;//大王小王的个数
        int num1 = 0;//中断牌数
        for (int i = 0; i < nums.length - 1; i++) {
            if (nums[i] == 0) {
                num0++;
                continue;
            }
            if (nums[i + 1] - nums[i] > 1) {
                num1 += (nums[i + 1] - nums[i] - 1);
            } else if (nums[i + 1] - nums[i] == 0) {
                return false;
            }
        }
        if (num0 >= num1) {
            return true;
        } else {
            return false;
        }
    }
}
